JSBool JS_StringToValue()

Description Stores a string return value in a jsval.
Arguments JSContext *cx, char *bytes, size_t sz, jsval *vp
cx is the opaque JSContext pointer that was passed to the JavaScript function.
bytes is the string to be stored in the jsval. The string data is copied, so the caller should free the string when it is no longer needed. If the string size is not specified (see the sz argument), then the string must be null terminated.
sz is the size of the string, in bytes. If sz is 0, then the length of the null-terminated string is computed automatically.
vpis a pointer to the jsval into which the contents of the string should be copied.
Returns A Boolean value indicating success (JS_TRUE) or failure (JS_FALSE).